﻿using System.Text;

namespace Dijiang.Values
{
    public class DList : DSequence
    {
        public DList(){ }

        public DList(IEnumerable<DValue> items) : base(items) { }

        public DList(params DValue[] items) : base(items) { }

        public override DValue Copy()
        {
            return new DList(CopyCell());
        }

        public override DValue Eval(CmdEnv env)
        {
            return this;
        }

        public override string ToString()
        {
            if (Count == 0) return "[]";

            var builder = new StringBuilder();
            builder.Append('[');
            foreach (var item in items)
            {
                builder.Append(item.ToString());
                builder.Append(' ');
            }
            builder.Remove(builder.Length - 1, 1);
            builder.Append(']');
            return builder.ToString();
        }
    }
}